'''
Created on Jun 21, 2011

@author: jchang
'''
import twitter
import json

def main():
    ts=twitter.Twitter(domain="search.twitter.com")
    querytext="HTC issue"
    search_results = []
    for page in range(1,6):
        search_results.append(ts.search(q=querytext, rpp=100, page=page))
        #print search_results[page-1]
    
    tweets=[]
    for result in search_results:
        for r in result['results']:
            tweets.append(r['text'])
    
    print tweets

    
    #ts.search(q="HTC")
    #output = open('/tmp/spam', 'w')
    
#    output = open ('search_result_htc issue.xml','w')
#    output.write(json.dumps(search_results,indent=1))
    #print json.dumps(search_results,indent=1)
    #json.dumps(search_results, skipkeys, ensure_ascii, check_circular, allow_nan, cls, indent, separators, encoding, default) 


if __name__ == '__main__':
    main()


    

#if __name__ == "__main__":
#    main()